namespace DataModels.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class TripReportUploading : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Activities",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Description = c.String(),
                        Comments = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.TripReportDistricts",
                c => new
                    {
                        DistrictId = c.Int(nullable: false),
                        TripReportId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.DistrictId, t.TripReportId })
                .ForeignKey("dbo.District", t => t.DistrictId, cascadeDelete: true)
                .ForeignKey("dbo.TripReports", t => t.TripReportId, cascadeDelete: true)
                .Index(t => t.DistrictId)
                .Index(t => t.TripReportId);
            
            CreateTable(
                "dbo.TripReports",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Filename = c.String(nullable: false, maxLength: 250),
                        Comments = c.String(maxLength: 1000),
                        SpecialActivityId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Activities", t => t.SpecialActivityId, cascadeDelete: true)
                .Index(t => t.SpecialActivityId);
            
            CreateTable(
                "dbo.TripReportMonths",
                c => new
                    {
                        TripReportId = c.Int(nullable: false),
                        ReportMonth = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.TripReportId, t.ReportMonth })
                .ForeignKey("dbo.TripReports", t => t.TripReportId, cascadeDelete: true)
                .Index(t => t.TripReportId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.TripReportMonths", "TripReportId", "dbo.TripReports");
            DropForeignKey("dbo.TripReportDistricts", "TripReportId", "dbo.TripReports");
            DropForeignKey("dbo.TripReports", "SpecialActivityId", "dbo.Activities");
            DropForeignKey("dbo.TripReportDistricts", "DistrictId", "dbo.District");
            DropIndex("dbo.TripReportMonths", new[] { "TripReportId" });
            DropIndex("dbo.TripReports", new[] { "SpecialActivityId" });
            DropIndex("dbo.TripReportDistricts", new[] { "TripReportId" });
            DropIndex("dbo.TripReportDistricts", new[] { "DistrictId" });
            DropTable("dbo.TripReportMonths");
            DropTable("dbo.TripReports");
            DropTable("dbo.TripReportDistricts");
            DropTable("dbo.Activities");
        }
    }
}
